<!--************************************************************ -->
<!--* 文件创建日期：2010                                  * -->
<!--* 文件修改日期：			                                   * -->
<!--************************************************************ -->
<!--JSP初始化设置-->
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.infomanage.po.*" %>
<%@page import="com.infomanage.vo.*" %>
<%@page import="com.infomanage.enums.*"%>
<%@page import="com.infomanage.service.plan.*"%>
<%@page import="com.infomanage.util.Consts"%>
<%  response.addDateHeader("Expires", 0);response.setHeader("Pragma","no-cache"); response.setHeader("Cache-Control","no-cache");%>
<%
	request.setCharacterEncoding("UTF-8");
	String checkId = request.getParameter("checkId");
	if(checkId == null) checkId = "";
	PreventcheckPlanItem checkItem = PreventCheckPlanService.loadPreventCheckPlan(request, response, out);
	String personId = "";
	int deptId = -1;
	String personname = "";
	String deptname = "";
	String dealResult = "";
	String gasParams = "";
	String imgDir = "";
	String place = "";
	String problem="";
	String route = "";
	String timestamp = "";
	String gasCh4 = "";
	String gasCo2 = "";
	String gasCo = "";
	String gasO2 = "";
	String gasT = "";
	if(checkItem != null) {
		PreventcheckPlan preventCheck = checkItem.getBean();
		Department dept = checkItem.getDept();
		personId = preventCheck.getPersonId();
	    deptId = preventCheck.getDeptId();
	    personname = preventCheck.getPersonName();
	    deptname = dept.getPath();
	    dealResult = preventCheck.getDealResult();
	    gasCh4 = preventCheck.getGasCh4();
	    gasCo = preventCheck.getGasCo();
	    gasCo2 = preventCheck.getGasCo2();
	    gasO2 = preventCheck.getGasO2();
	    gasT = preventCheck.getGasT();
	    imgDir = preventCheck.getImgDir();
	    place = preventCheck.getPlace();
	    problem = preventCheck.getProblem();
	    route = preventCheck.getRoute();
	    timestamp = preventCheck.getTimestamp();
	} 
%>
<html>
<head>
	<title>防预检查记录</title>
	<link href="../../css/table.css" rel="stylesheet" type="text/css">
	<link href="../../css/calendar.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="../../js/calendar.js"></script>
	<script type="text/javascript" src="../../js/common.js"></script>
	<script type="text/javascript">
	var legendName="";
	   function init() {
		   if("" != "<%=checkId%>") { // 修改
		       document.getElementById("legend").style.display = "none";
		       document.getElementById("uploadLink").style.display = "";
		       legendName = "<%=imgDir%>";
			   form1.personId.value = "<%=personId%>";	
			   form1.deptId.value = "<%=deptId%>";
			   form1.personname.value = "<%=personname%>";	
			   form1.deptname.value = "<%=deptname%>";
			   form1.timestamp.value = "<%=timestamp%>";
			   form1.place.value = "<%=place%>";
			   form1.route.value = "<%=route%>";
			   form1.problem.value = "<%=problem%>";
			   form1.dealResult.value = "<%=dealResult%>";
			   form1.gasCh4.value = "<%=gasCh4%>";
			   form1.gasCo2.value = "<%=gasCo2%>";
			   form1.gasCo.value = "<%=gasCo%>";
			   form1.gasO2.value = "<%=gasO2%>";
			   form1.gasT.value = "<%=gasT%>";
			   form1.imgDir.value = "<%=imgDir%>";
		   }
		   form1.personname.title = form1.personname.value;
	   }
	   
	   
      	// 提交
	   function doSubmit(){
	   		if(validate()){
	   			return;
	   		}
		 	if("" == "<%=checkId%>") {
		 		form1.actionType.value = "add";
			}else {
		 		form1.actionType.value = "modify";
			}
		 	form1.submit();
	   }
	   
	   function validate(){
	   		if(form1.deptId.value == ""){
	   			alert("队别不能为空！");
	   			return true;
	   		}
	   		if(form1.personId.value == ""){
	   			alert("预检人员不能为空！");
	   			return true;
	   		}
	   		
	   		if(form1.place.value.length > 100){
	   				alert("检查地点不能超过100个字！");
	   				return true;
	   	    }
	   		
	   		if(form1.route.value.length > 5000){
	   				alert("行车路线不能超过1000个字！");
	   				return true;
	   	    }
	   		
	   		if(form1.problem.value.length > 5000){
	   				alert("发现问题不能超过5000个字！");
	   				return true;
	   	    }
	   		
	   		if(form1.dealResult.value.length > 5000){
	   				alert("处理结果不能超过5000个字！");
	   				return true;
	   	    }
	   	    
	   		return false;
	   }
	   
	   function showError(error){
		   alert(error);
	   }

	   function showInfo(info){
		   alert(info);
		   window.returnValue = "ok";
		   window.close();
	   }
	   
	   function uploadLegend(){
	   		var url = "preventCheck_upload.jsp";
			var width = '400px';
			var height ='200px';
			var arg = "dialogHeight:" + height + ";dialogWidth:" + width + ";status:no;location:no;";
			var returnValue = window.showModalDialog(url, "", arg);
			if(returnValue){
				var legend = document.getElementById("legend");
				legendName = returnValue;
				form1.imgDir.value = legendName;
				var uploadLink = document.getElementById("uploadLink");
				uploadLink.style.display = "none"
				legend.style.display = "";
			}
	   }
	   
	   function showLegend(pictureDir){
			var url = encodeURI("preventCheck_legend.jsp?pictureDir="+pictureDir);
			var width = '700px';
			var height ='500px';
			var arg = "dialogHeight:" + height + ";dialogWidth:" + width + ";status:no;location:no;edge=sunken;center=yes;resizable=yes;Minimize=yes;Maximize=yes";
			var returnValue = window.showModalDialog(url, "", arg);
			if(returnValue){
				dataFrame.location.reload();
			}
		}
		
		function onCheckboxClick(nodeObj){
			var existPerson = form1.personId.value;
			var existPersonName = form1.personname.value;
			var nodePersonName = nodeObj.nodeName;
			var nodePersonId = nodeObj.nodeId;
			var existPersonArray = existPerson.split(";");
			var existPersonNameArray = existPersonName.split(";");
			var isHasFlag = false;
			for(var i = 0; i < existPersonArray.length; i++){
	             if(existPersonArray[i] == nodePersonId){
	                 isHasFlag = true;
	                 break;
	             }
			}
			if(isHasFlag){
				existPersonArray.remove(i);
				existPersonNameArray.remove(i);
			}
			else{
	 			if(existPersonArray[0] == "" || typeof(existPersonArray[0]) == 'undefined'){
	 			   existPersonArray = new Array();
	 			   existPersonNameArray = new Array();
	 	 		 }
			     existPersonArray.push(nodePersonId);
			     existPersonNameArray.push(nodePersonName);
			}
			form1.personId.value = existPersonArray.join(";");
			form1.personname.value = existPersonNameArray.join(";");
			form1.personname.title = form1.personname.value;
		}
		
		function showPersonTree(obj){
			showTree(obj, "../common/personSelectTree.jsp?personId=" + '<%=personId%>');
		}
	</script>
</head>
<body  rightmargin="0" bottommargin="0" leftmargin="0" onclick="clickBody();" onload="init();">
	<form name="form1" action="preventCheck_action.jsp" method="post" target="actionFrame">
	<input type="hidden" name="checkId" value="<%=checkId%>">
	<input type="hidden" name="actionType">
	<input type="hidden" name="imgDir">
	<table class="dialogTable" cellpadding="0" cellspacing="0">
		<!-- 表头-->
		<tr class="dialogTableHeader">
			<td>防预检查记录</td>
		</tr>
		<!-- 表数据-->
		<tr class="dialogTableContent">
			<td>
				<!-- 数据项 -->
				<table class="dataTable">
					<col width="14%">
					<col width="28%">
					<col width="18%">
					<col width="8%">
					<col width="8%">
					<col width="8%">
					<col width="8%">
					<col width="8%">
					<tr>
						<td class="field">
							队别
						</td>
						<td>
							<span style="width:145px;
								background-position: right;
								background-image: url('../../img/dropdownForSelect.gif');
								background-repeat: no-repeat;
								cursor: hand;"
							 	onclick="showTree(this, '../common/deptTree.jsp');" treeSelect="true">
								<input name="deptname" value="" style="width: 145px;" readonly="readonly" treeSelect="true"><input name="deptId" value="" type="hidden">
							</span>
						</td>
						<td class="field">
							时间
						</td>
						<td colspan="5">
							<input type="text" style="width: 195px;cursor: hand;" name="timestamp" id="time" onClick="return showCalendar(this.id, 'y-mm-dd');" readonly="readonly"><img 
										src="../../img/tip_calender.gif" style="cursor: hand;" width="16" height="16" onClick="return showCalendar('time', 'y-mm-dd');">
						</td>
					</tr>
					<tr>
						<td class="field">
							检查地点
						</td>
						<td>
							<input name="place" value="" style="width: 100%;">
						</td>
						<td class="field">
							预检人员
						</td>
						<td colspan="5">
							<span class="treeSpan" onclick="showPersonTree(this);" treeSelect="true">
								<input name="personname" value="" style="width: 214px;" treeSelect="true" title=""><input name="personId" value="" type="hidden">
							</span>
						</td>
					</tr>
					<tr>
						<td class="field">
							行动路线
						</td>
						<td colspan="7">
							<input name="route" type="text" style="width: 100%">
						</td>
					</tr>
					<tr>
						<td rowspan="4" class="field">
							示意图
						</td>
						<td rowspan="4">
							<a id="uploadLink" href="#" onclick="uploadLegend();">上传图片</a>
							<a id="legend"  href="#" onclick="showLegend(legendName);" style="display:none">查看图片</a>
						</td>
						<td rowspan="2" class="field">
							重点部位气体参数
						</td>
						<td align="center">
							CH4
						</td>
						<td align="center">
							CO2
						</td>
						<td align="center">
							CO
						</td>
						<td align="center">
							O2
						</td>
						<td align="center">
							T
						</td>
					</tr>
					<tr>
						<td>
							<input name="gasCh4" type="text" style="width: 100%">
						</td>
						<td>
							<input name="gasCo2" type="text" style="width: 100%">
						</td>
						<td>
							<input name="gasCo" type="text" style="width: 100%">
						</td>
						<td>
							<input name="gasO2" type="text" style="width: 100%">
						</td>
						<td>
							<input name="gasT" type="text" style="width: 100%">
						</td>
					</tr>
					<tr>
						<td class="field">
							发现问题
						</td>
						<td colspan="5" style="height: 80px">
							<textarea style="height: 100%;width: 100%" name="problem"></textarea>
						</td>
					</tr>
					<tr>
						<td class="field">
							处理结果
						</td>
						<td colspan="5" style="height: 80px">
							<textarea style="height: 100%;width: 100%" name="dealResult"></textarea>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td colspan="8" class="tableBtn">
				<span onclick="doSubmit();">确定</span>
				<span onclick="window.close();">取消</span>
			</td>
		</tr>
		<tr valign="top">
			<td colspan="8">
				&nbsp;
			</td>
		</tr>
	</table>
	<iframe src="#" frameborder="0" id="treeFrame" name="frame" style="display: none;position: absolute;"></iframe>
	<iframe src="#" name="actionFrame" style="display: none;"></iframe>
	</form>
</body>
</html>